#include "chapter14_winec.h"
#include "chapter14_person.h"
#include <iostream>
#include <string>
#include <cstdlib> //for rand() srand()
#include <ctime> //for time()



Wine::Wine(const char * l, int y, const int yr[], const int bot[])
{
	fullname = l;
	yearsNum = y;
	pa.Set(ArrayInt(yr, yearsNum), ArrayInt(bot, yearsNum));
}

Wine::Wine(const char * l, int y)
{
	fullname = l;
	yearsNum = y;
}

void Wine::GetBottles()
{
	ArrayInt yr(yearsNum), bt(yearsNum);
	for (int i = 0; i < yearsNum; i++)
	{
		cout << "Enter the year: ";
		cin >> yr[i];
		cout << "Enter the bottles: ";
		cin >> bt[i];
	}
	while (cin.get() != '\n')
		continue;
	pa.Set(yr, bt);
}

string & Wine::Label()
{
	return fullname;
}

void Wine::Show() const
{
	cout << "Wine: " << fullname << endl;
	cout << "\tYear\tBottles\n";
	pa.Show(yearsNum);
}

int Wine::sum() const
{
	return pa.Sum();
}

//Person methods
Person::~Person() { }

//protect methods
void Person::Data() const
{
	cout << "First Name: " << firstname << endl;
	cout << "Last Name: " << lastname << endl;
}

void Person::Get() 
{
	cout << "Enter the first name: ";
	getline(cin, firstname);
	cout << "Enter the last name: ";
	getline(cin, lastname);
}

//Gunslinger methods
void Gunslinger::Data() const
{
	cout << "The nick number of the Gun: " << counts << endl;
	cout << "The drop time of gunslinger: " << gunTime << endl;
}

void Gunslinger::Get()
{
//	Person::Get();
	cout << "Please enter the nick number of the Gun: ";
	cin >> counts;
	cout << "Please enter the drop time of gunslinger: ";
	cin >> gunTime;
	while (cin.get() != '\n')
		continue;
}

void Gunslinger::Show() 
{
	cout << "Catogory: Gunslinger\n";
	Person::Data();
	Data();
}

void Gunslinger::Set()
{
	Person::Get();
	Get();
}

//PokerPlayer methods
void PokerPlayer::Data() const
{
//	Person::Data();
}

void PokerPlayer::Get()
{
//	Person::Get();
}

int PokerPlayer::Draw()
{
	return (rand() % 52 + 1);
}

void PokerPlayer::Set()
{
	Person::Get();
	Get();
}

void PokerPlayer::Show() 
{
	Person::Data();
	Data();
}

void BadDude::Data() const
{
	Gunslinger::Data();
	PokerPlayer::Data();
}

void BadDude::Get()
{
	Gunslinger::Get();
	PokerPlayer::Get();
}

void BadDude::Set()
{
	Person::Get();
	Get();
}

void BadDude::Show()
{
	Person::Data();
	Data();
	for (int i = 0; i < 10; i++)
		cout << Cdraw() << " poker cards";
}

int BadDude::Cdraw()
{
	return (rand() % 52 + 1);
}






